<template>
  <div class="home">
    <h2>count: {{ counterStore.count }}</h2>
    <button @click="increment">count++</button>
    <button @click="incrementNum">count+num</button>
    <ul>
      <template v-for="item in useHomeStore.banners" :key="item.acm">
        <!-- <img :src="item.image"></img> -->
        <li>{{ item.title }}</li>
      </template>
    </ul>
  </div>
</template>

<script setup>
  import useUser from '@/stores/user'
  import useCounter from '@/stores/counter'
  import usehome from '@/stores/home'
  import { toRefs } from 'vue'
  import { storeToRefs } from 'pinia' 

  const counterStore = useCounter()
  function increment() {
    counterStore.increment()
  }
  function incrementNum() {
    counterStore.incrementNum(5)
  }

  const useHomeStore = usehome()
  // const data = useHomeStore.fetchHomeData() // 返回的是promise对象
  useHomeStore.fetchHomeData().then(res => {
    console.log("fetchHomeData已发送完成")  
    console.log(res)
  }
  )

</script>

<style scoped>
</style>